<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>统计各位数字都不同的数字个数</title>
</head>

<body>
  <script>
    var countNumbersWithUniqueDigits = function (n) {
      if (n === 0) {
        return 1;
      }
      if (n === 1) {
        return 10;
      }
      let res = 10, cur = 9;
      for (let i = 0; i < n - 1; i++) {
        cur *= 9 - i;
        res += cur;
      }
      return res;
    };
    console.log(countNumbersWithUniqueDigits(2))
  </script>
</body>

</html>